package com.company.genealogy.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.company.genealogy.web.dto.BranchDTO;
import com.company.genealogy.web.entity.Branch;
import com.company.genealogy.web.mapper.BranchMapper;
import com.company.genealogy.web.service.BranchService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BranchServiceImpl extends ServiceImpl<BranchMapper, Branch> implements BranchService {
    
    @Override
    public IPage<BranchDTO> getBranchListWithNames(int page, int size, Long clanId) {
        Page<BranchDTO> pageParam = new Page<>(page, size);
        return baseMapper.selectBranchListWithNames(pageParam, clanId);
    }
    
    @Override
    public List<Branch> getBranchesByClanId(Long clanId) {
        QueryWrapper<Branch> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("clan_id", clanId);
        queryWrapper.orderByAsc("name");
        return this.list(queryWrapper);
    }
} 